package tju.mic.medicine.ws.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import tju.mic.medicine.ws.models.Department;
import tju.mic.medicine.ws.models.DepartmentList;
import tju.mic.medicine.ws.models.Disease;
import tju.mic.medicine.ws.models.DiseaseList;
import tju.mic.medicine.ws.models.DiseaseReasonList;
import tju.mic.medicine.ws.repo.DepartRepository;
import tju.mic.medicine.ws.repo.DiseaseRepository;

@Component("diseaseService")
public class DiseaseServiceImp implements DiseaseService{

    @Autowired
    private DiseaseRepository diseaseRepository;
    @Autowired
    private DepartRepository departRepository;
    @Override
    public Disease getDiseaseById(Long diseaseId) throws Exception {
        return diseaseRepository.findOne(diseaseId);
    }

    @Override
    public Disease saveDisease(Disease disease) throws Exception {
        return diseaseRepository.save(disease);
    }

    @Override
    public void deleteDisease(Long diseaseId) throws Exception {
        diseaseRepository.delete(diseaseId);
    }

    @Override
    public DiseaseList getListByDepart(Long departId) throws Exception {
        return diseaseRepository.getListByDepart(departId);
    }

    @Override
    public DiseaseList searchDisease(Long departId, String diseaseTypeId, String diseaseName) throws Exception {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public DiseaseReasonList getDiseaseReasonByDiseaseId(Long diseaseId) throws Exception {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public Department getDepartById(Long departId) throws Exception {
        return departRepository.findOne(departId);
    }

    @Override
    public DepartmentList getAllDepart() throws Exception {
        return departRepository.getAllList();
    }
    
}
